package com.example.test.controller;


import com.example.test.servive.ChatService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/chat")
public class ChatController {

    @Resource
    private ChatService chatService;

    /**
     * 加入房间
     * @param roomId
     * @param userId
     */
    @GetMapping("/join")
    public ResponseEntity<String> joinRoom(String roomId, String userId) {
        return ResponseEntity.ok(chatService.joinRoom(roomId, userId));
    }

    /**
     * 离开房间
     * @param roomId
     * @param userId
     */
    @GetMapping("/leave")
    public ResponseEntity<String> leaveRoom(String roomId, String userId) {
        return ResponseEntity.ok(chatService.leaveRoom(roomId, userId));
    }
}
